<template>
  <div class="ly-wrap">
    <div class="sub-title">当前小区：{{name}}</div>
    <yd-infinitescroll :callback="getHistory" ref="infinitescrollDemo">
      <div class="list" slot="list">
        <yd-cell-group v-for="item in repairList" :key="item.id">
          <yd-cell-item>
            <span slot="left">时间</span>
            <span slot="right">{{item.createTime}}</span>
          </yd-cell-item>
          <yd-cell-item>
            <span slot="left">状态</span>
            <span slot="right" v-if="item.state==1">未处理</span>
            <span slot="right" v-if="item.state==2" style="color: red;">处理中</span>
            <span slot="right" v-if="item.state==3" style="color: green;">已处理</span>
          </yd-cell-item>
          <yd-cell-item>
            <span slot="left">投诉内容</span>
            <span slot="right">{{item.content}}</span>
          </yd-cell-item>
        </yd-cell-group>
      </div>
      <!-- 数据全部加载完毕显示 -->
      <span slot="doneTip" class="dbTips">数据加载完毕~~</span>
      <yd-icon name="more" slot="loadingTip" size=".42rem"></yd-icon>

    </yd-infinitescroll>

  </div>

</template>

<script>
  import http from "../../http";
  import storage from "../../store/storage.js";

  export default {

    data() {
      return {
        tab2: 0,
        name: "",
        housingId: '',
        info: {
          content: '',
          number: '',
        },
        repairList: [],
        loading: false,
        //  历史记录
        historyList: [],
        pageNum: 1,
        pageSize: 15,

      };
    },
    created: function () {
      this.init();
      this.getHistory();
    },
    methods: {

      init: function () {
        this.name = storage.getObj("housingId").name;
        this.housingId = storage.getObj("housingId").id;
      },

      getHistory: function () {
        let historyList = [];
        let params = {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          housingId: storage.getObj("housingId").id,
          typeInt: 2,
        };
        http.post('/communityApps/reportms/getReport', params).then(res => {
          if (res.data.code == 20000) {
            historyList = res.data.data.list;
            this.repairList = [...this.repairList, ...historyList];
          } else {
            this.$dialog.toast({
              mes: res.data.message,
              timeout: 2000
            });
          }
          if (historyList.length < this.pageSize) {
            /* 所有数据加载完毕 */
            this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
            return;
          }
          /* 单次请求数据完毕 */
          this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');
          this.pageNum++;
        });
      },

    }
  }
  ;
</script>


<style scoped lang="scss">


  .sub-title {
    color: #666;
    font-size: .28rem;
    line-height: 0.4rem;
    padding: .2rem .24rem .1rem;
  }

  .clear {
    clear: both;
  }


</style>
